package com.dede.rxbase.config;

import android.app.Application;

import com.dede.rxbase.comm.ActivityLifecycle;

/**
 * @author hsh
 *         2018/1/18 13:52.
 */
public final class BaseConfig {

    private static volatile BaseConfig mInstance;

    public static BaseConfig init(Application application) {
        if (mInstance == null) {
            synchronized (BaseConfig.class) {
                if (mInstance == null) {
                    mInstance = new BaseConfig(application);
                }
            }
        }
        return mInstance;
    }

    public static BaseConfig getInstance() {
        if (mInstance == null) {
            throw new NullPointerException("BaseConfig no init");
        }
        return mInstance;
    }

    private boolean debug = true;// 打印组件生命周期
    private boolean noActionBar = false;// 没有原生ActionBar

    private BaseConfig(Application application) {
        application.registerActivityLifecycleCallbacks(ActivityLifecycle.getInstance());
    }


    public boolean isDebug() {
        return this.debug;
    }

    public boolean isNoActionBar() {
        return this.noActionBar;
    }

    /**
     * debug模式，打印组件生命周期
     * @param debug
     * @return
     */
    public BaseConfig debug(boolean debug) {
        this.debug = debug;
        return this;
    }

    /**
     * 没有默认ActionBar
     * @return
     */
    public BaseConfig noActionBar() {
        this.noActionBar = true;
        return this;
    }
}
